﻿alter procedure [dbo].[usp_AddAndUpdateTask]      
@projectId as int,      
@ReleaseId as int,      
@TaskId as int,      
@TaskType as nvarchar(50),      
@TaskShortName as nvarchar(50),      
@Description as nvarchar(max),      
@Status as int,      
@InitialEstimation as int,      
@CurrentEstimation as int,
@Priority as int     
      
as      
if @TaskId !=0    
  
begin    
 update TblTasks set    
 ProjectId=@ProjectId,ReleaseId=@ReleaseId,    
 TaskType=@TaskType,TaskShortName=@TaskShortName,    
 Description=@Description,Status=@Status,InitialEstimation=@InitialEstimation,      
 currentEstimation=@currentEstimation,Elapsed=0,Remaining=0,Priority = @Priority where taskId=@TaskId    
end    
else  
  
begin    
    
 insert into TblTasks (ProjectId,ReleaseId,    
 TaskType,TaskShortName,    
 Description,Status,InitialEstimation,      
 currentEstimation,Elapsed,Remaining,Priority)  values      
 (@ProjectId,@ReleaseId,@TaskType,@TaskShortName,@Description,@Status,@InitialEstimation,      
 @currentEstimation,0,0,@Priority)     
end  